package com.tin.dao;

import com.tin.bean.User;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;

/**
 * @author liming_oicq@163.com
 * @date 2018-10-13 10:54
 */

//如果不在启动程序使用MapperScan，就需要在每个DAO接口上使用@Mapper
public interface UserDao extends CrudRepository<User, Integer> {
    User findByUsernameAndPassword(String username, String password);

    User findByUsername(String username);

    @Transactional
    @Modifying
    @Query(value = "INSERT INTO user( username, password, mail, create_Date, role ) VALUES(?1, ?2, ?3, ?4, ?5)", nativeQuery = true)
    Integer insert(String username, String password, String mail, String createDate, Integer role);
}
